package com.example.science.consumer;


import com.example.science.util.RedisUtil;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class DeleteCacheKeyConsumer {
    @Resource
    private RedisUtil redisUtil;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "delete_cache_queue",durable = "true"),
            exchange = @Exchange(name="delay-exchange"),
            key = "delete"
    ))
    @RabbitHandler
    public void deleteCachKey(String cacheKey){
        redisUtil.del(cacheKey);
    }
}
